/*    */ package com.zimbra.cs.db;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class DbTableMaintenance
/*    */ {
/*    */   public static int runMaintenance()
/*    */     throws ServiceException
/*    */   {
/* 30 */     if (!(Db.getInstance() instanceof MySQL)) {
/* 31 */       ZimbraLog.mailbox.warn("Table maintenance only supported for MySQL.");
/* 32 */       return 0;
/*    */     }
/*    */     
/* 35 */     int numTables = 0;
/* 36 */     DbResults results = DbUtil.executeQuery("SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'zimbra' OR table_schema LIKE 'mboxgroup%'", new Object[0]);
/*    */     
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/* 42 */     while (results.next()) {
/* 43 */       String dbName = results.getString("TABLE_SCHEMA");
/* 44 */       String tableName = results.getString("TABLE_NAME");
/* 45 */       String sql = String.format("ANALYZE TABLE %s.%s", new Object[] { dbName, tableName });
/* 46 */       ZimbraLog.mailbox.info("Running %s", new Object[] { sql });
/* 47 */       DbUtil.executeUpdate(sql);
/* 48 */       numTables++;
/*    */     }
/*    */     
/* 51 */     return numTables;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/db/DbTableMaintenance.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */